/*
2021-11-9
https://www.acwing.com/problem/content/4075/
*/ 
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>

using namespace std;
const int N=2e5+5;
int n,m;
int p[N],a[N],b[N],c[N];
int ans[N];
bool st[N];

priority_queue<int,vector<int>,greater<int>> q[4];
map<int,int>mp;

int main()
{
    cin>>n;
    for(int i=1;i<=n;i++) 
    {
        cin>>p[i];
        mp[p[i]]=i;
    }
    for(int i=1;i<=n;i++) 
    {
        cin>>a[i];
        q[a[i]].push(p[i]);
    }
    for(int i=1;i<=n;i++) 
    {
        cin>>b[i];
        q[b[i]].push(p[i]);
    }
    
    cin>>m;
    for(int i=1;i<=m;i++) 
    {
        cin>>c[i];
        if(q[c[i]].size())
        {
            while(!ans[i] && q[c[i]].size())
            {
                int t=q[c[i]].top();
                q[c[i]].pop();
                if(st[mp[t]]) continue;
                else
                {
                    st[mp[t]]=true;
                    ans[i]=t;
                }
            }
        }
        if(!ans[i])
            ans[i]=-1;
    }
    for(int i=1;i<=m;i++)
        cout<<ans[i]<<' ';
    
    return 0;
}
